package com.wenlin.myproduction.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.base.BaseActivity;
import com.wenlin.myproduction.base.BaseSwipeActivity;
import com.wenlin.myproduction.util.Checker;
import com.wenlin.myproduction.util.ToastUtils;
import com.wenlin.myproduction.util.UI;
import com.wenlin.myproduction.util.ValCommon;
import com.wenlin.myproduction.widget.InfoAnimView;

import butterknife.BindView;
import butterknife.OnClick;

public class InfoAnimViewActivity extends BaseSwipeActivity {

    @BindView(R.id.iav)
    InfoAnimView iav;

    @Override
    public int getContentView() {
        return R.layout.activity_info_anim_view;
    }

    public static void start(BaseActivity activity) {
        Intent intent = new Intent(activity, InfoAnimViewActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(ValCommon.INFO_ANIM_VIEW);
        iav.setDesc("378.9");
        iav.setClickListener(new InfoAnimView.clickListener() {
            @Override
            public void clickCiv() {
                ToastUtils.getInstance().showInfo("点击了头像");
            }

            @Override
            public void clickBtn() {
                ToastUtils.getInstance().showInfo("点击了按钮，开始显示信息");
            }

            @Override
            public void clickInfo(String desc) {
                ToastUtils.getInstance().showInfo("点击了信息");
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (Checker.notNull(iav)) iav.release();
    }

    @OnClick({R.id.tv})
    void click(View view) {
        switch (view.getId()) {
            case R.id.tv:
                UI.setInfoViewCiv(this, "https://himg.bdimg.com/sys/portraitn/item/bcd0bac1cef44927", iav);
//                Glide.with(this)
//                        .load("http://portrait7.sinaimg.cn/2947893190/blog/180")
//                        .placeholder(R.mipmap.ic_default_head_girl)
//                        .error(R.mipmap.ic_default_head_girl)
//                        .downloadOnly(new SimpleTarget<File>() {
//                            @Override
//                            public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
//                                iav.setCivPath(resource.getAbsolutePath());
//                            }
//                        });
                break;
            default:
        }
    }
}
